package h.a.a.i;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;

/* compiled from: IdentityScopeObject */
public class c<K, T> implements a<K, T> {
    public final HashMap<K, Reference<T>> a = new HashMap();
    public final ReentrantLock b = new ReentrantLock();

    public void a(K k, T t) {
        this.a.put(k, new WeakReference(t));
    }

    public boolean b(K k, T t) {
        this.b.lock();
        try {
            boolean z;
            if (get(k) != t || t == null) {
                z = false;
            } else {
                remove(k);
                z = true;
            }
            this.b.unlock();
            return z;
        } catch (Throwable th) {
            this.b.unlock();
        }
    }

    public void c() {
        this.b.unlock();
    }

    public void clear() {
        this.b.lock();
        try {
            this.a.clear();
        } finally {
            this.b.unlock();
        }
    }

    public void d(Iterable<K> iterable) {
        this.b.lock();
        try {
            for (K remove : iterable) {
                this.a.remove(remove);
            }
        } finally {
            this.b.unlock();
        }
    }

    public void e() {
        this.b.lock();
    }

    public T f(K k) {
        Reference reference = (Reference) this.a.get(k);
        return reference != null ? reference.get() : null;
    }

    public void g(int i) {
    }

    public T get(K k) {
        this.b.lock();
        try {
            Reference reference = (Reference) this.a.get(k);
            return reference != null ? reference.get() : null;
        } finally {
            this.b.unlock();
        }
    }

    public void put(K k, T t) {
        this.b.lock();
        try {
            this.a.put(k, new WeakReference(t));
        } finally {
            this.b.unlock();
        }
    }

    public void remove(K k) {
        this.b.lock();
        try {
            this.a.remove(k);
        } finally {
            this.b.unlock();
        }
    }
}
